;(function($){
	$.each({UDF:'undefined',FN:'function',STR:'string',NUM:'number',BL:'boolean',OBJ:'object'
		,userAgent:navigator.userAgent.toLowerCase()
		,isStrict:document.compatMode=='CSS1Compat'
		,isOpera:/opera/,isChrome:/chrome/,isWebKit:/webkit/
        ,isWindows:/windows|win32/,isMac:/macintosh|mac os x/,isAir:/adobeair/,isLinux:/linux/
        ,isSecure:/^https/i.test(window.location.protocol)
        ,__idSeed:1,getIdSeed:function(){return 'tcid_'.concat(++$.__idSeed);}
		,isUDF:function(obj){return typeof(obj)==$.UDF;}
		,isNotNull:function(obj){return typeof(obj)!=$.UDF&&obj!=null;}
		,isArray:function(obj){return typeof(obj)!=$.UDF&&(obj instanceof Array);}
		,isString:function(obj){return typeof(obj)==$.STR;}
		,isNumber:function(obj){return typeof(obj)==$.NUM;}
		,isBoolean:function(obj){return typeof(obj)==$.BOOL;}
		,isObject:function(obj){return typeof(obj)==$.OBJ;}
		,isDictionary:function(obj){return String(obj).indexOf(" Object")!=-1;}
		,id:function(el){
			var $el=el?$(el):null;
			var elId=$el&&$el.size()>0?$el.get(0).id:$.getIdSeed();
			if(!elId){elId=$.getIdSeed();$el.get(0).id=elId;}
			return elId;
		}
	},function(name,value){
		if(name in $){
		}else if(value instanceof RegExp){
			$[name]=value.test($.userAgent);
		}else{
			$[name]=value;
		}
	});
	$.isSafari=!$.isChrome&&/safari/.test($.userAgent);
	$.isSafari3=$.isSafari&&/version\/3/.test($.userAgent);
	$.isSafari4=$.isSafari&&/version\/4/.test($.userAgent);
	$.isIE=!$.isOpera&&/msie/.test($.userAgent);
	$.isIE7=$.isIE&&/msie 7/.test($.userAgent);
	$.isIE8=$.isIE&&/msie 8/.test($.userAgent);
	$.isIE6=$.isIE&&!$.isIE7&&!$.isIE8;
	$.isGecko=!$.isWebKit&&/gecko/.test($.userAgent);
	$.isGecko3=$.isGecko&&/rv:1\.9/.test($.userAgent);
	$.isBorderBox=$.isIE&&!$.isStrict;
	$.Class=function(members){
		var fn =function(){
			if(arguments[0]!='no_init'){return this.init.apply(this, arguments);}
		};
		fn.prototype=members; $.extend(fn, $.Class.prototype);
		return fn;
	};
	$.Class.prototype={
	    extend: function(members) {
	        var parent = new this('no_init');
	        for(k in members) {
	            var prev = parent[k];
	            var cur = members[k];
	            if (prev && prev != cur && typeof cur == 'function') {cur = this._parentize(cur, prev);}
	            parent[k] = cur;
	        }
	        return new $.Class(parent);
	    },
	    implement: function(members) {$.extend(this.prototype, members);},
	    _parentize: function(cur, prev) {
	        return function(){this.parent = prev; return cur.apply(this, arguments);};
	    }
	};
	$.Object=new $.Class({init:function(){}});
	$.Widget=$.Object.extend({});
	
	/*IE CollectGarbage*/if($.isIE){setInterval(CollectGarbage, 10000);}
	$.extend({
		json:function(){
			var result, url,successFun,data,sync,type;
			for(var i=0;i<arguments.length;i++){
				type=typeof(arguments[i]);
				if(type=='string'){url=arguments[i];}
				else if(type=='function'){successFun=arguments[i];}
				else if(type=='boolean'){sync=arguments[i];}
				else if(type=='object'){data=arguments[i];}
			}
			url=url||'';successFun=successFun||$.noop;type=data?'POST':'GET';data=data||{};sync=sync||false;
			$.ajax({
				data:data,url:url,
				type:type,timeout:30000,
				contentType:"application/x-www-form-urlencoded; charset=UTF-8",
				async:sync,cache:false,
				global:false,
				dataType: "json",
				success: function(json){
					result=json;
					if(result&&result.error){
						var type=result.type||0, info=result.info||'', error=result.error;
					}else{successFun(result);}
				},error: function(){
					try{result=eval(arguments[0].responseText);}catch(err){}
					if(result){successFun(result);}
				}
			});
			return result;
		}
	});
	$.fn.extend({
		selectNode: function(){
			return this.each(function(){
				var text = this;
				if ($.browser.msie) {
					var range = document.body.createTextRange(); 
					range.moveToElementText(text); 
					range.select();
				} else if ($.browser.mozilla||$.browser.opera) { 
					var selection = window.getSelection(); 
					var range = document.createRange(); 
					range.selectNodeContents(text); 
					selection.removeAllRanges(); 
					selection.addRange(range); 
				} else if ($.browser.safari) { 
					var selection = window.getSelection(); 
					selection.setBaseAndExtent(text, 0, text, 1); 
				}
			});
		},disableSelection :function(){
			return this.each(function(){
				var target=this;
				if ('onselectstart' in target){ //IE route
					target.onselectstart=function(){return false;};
				}else if ('MozUserSelect' in target.style){ //Firefox route
					target.style.MozUserSelect='none';
				}else {//All other route (ie: Opera)
					target.onmousedown=function(){return false;};
				}
				target.style.cursor = 'default';
			});
		},page:function(url,params,callback){
			if(typeof(url)!=='string'){return this;}
			var off=url.indexOf(' ');var selector;var type='GET';var self=this;
			if(off>=0){selector=url.slice(off,url.length);url=url.slice(0,off);}
			if(params){if($.isFunction(params)){callback=params;params=null;}else if(typeof(params)==='object'){params=$.param(params,$.ajaxSettings.traditional);type='POST';}}
			$.ajax({url:url,type:type,dataType:'html',data:params,contentType:"application/x-www-form-urlencoded; charset=UTF-8",
				complete: function(res,status){
					if(status==='success'||status==='notmodified'){
						self.html(selector
								?$('<div />').append(res.responseText.replace(/<script(.|\s)*?\/script>/gi,'')).find(selector)
								:res.responseText);
						var children=self.children('.TCExecutable');var jsscript='';
						children.each(function(){jsscript=jsscript.concat('{',$(this).attr('script'),'}');});
						if(jsscript){eval(jsscript);}
					}
					if(callback){self.each(callback,[res.responseText,status,res]);}
				}
			});
			return this;
		}
	});
})(jQuery);